#ifndef CHAT_HH_
# define CHAT_HH_

# include <list>
# include <iostream>
# include "menu/menu.hh"

# include "text-img.hh"
# include <SDL/SDL.h>

# include "../action/action_queue.hh"

class Chat : public Menu
{
public:
  Chat (Vector2d pos, Vector2d size, int histo_size);
  ~Chat ();

  void activate ();
  void desactivate ();
  void switch_state ();

  void enable_switch ()
  {
    can_switch_ = true;
  }

  void erase_char ();
  void add_char (unsigned char c);

  void move_cursor_left ();
  void move_cursor_right ();
  void dispatch () const;
  void new_msg (const std::string& msg);

  // menu handling
  void size_max_set (Vector2d size_max);
  void hoover_action (Vector2d cursor);
  void click_action (Vector2d cursor, unsigned int button);

protected:
  unsigned int histo_size_;
  bool active_;

  std::list<TextImg*>* list_;
  TextImg* current_text_;
  std::string curr_;
  bool can_switch_;

  std::queue<Action*>* queue_;

  // number of lines that we can display
  int num_line_;
  // size of a line in pixel
  int line_size_;

  // offset for drawing the history
  unsigned int hist_offset_;

  // cursor handling
  unsigned int cur_offset_;

  // current line handling
  int width_line_;
  int pos_line_;
  int max_line_;
};

#endif /// !CHAT_HH_
